package com.winter.controller;

import com.winter.dto.req.ValidTestReq;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author Jinhao
 * @create 2023/02/03 15:17
 * @description
 */
@Slf4j
@RestController
@RequiredArgsConstructor
public class ValidTestController {

    /**
     * valid注解测试
     *
     * @param validTestReq 传参
     * @return string
     */
    @PostMapping("/valid/test")
    public String validTest(@Valid ValidTestReq validTestReq, BindingResult bindingResult) throws BindException {
        if (bindingResult.hasErrors()) {
            throw new BindException(bindingResult);
        }
<<<<<<< HEAD
        // test
=======
        // 测试：删除空行，标签推送001
        // 标签推送尝试-002
        // 标签推送完成，Jenkins参数化构建即可按tag打包
>>>>>>> parent of 3a5f50d (fix02)
        return validTestReq.getName();
    }
}
